home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / chips18b.zip / CHIPS.DOC < prev   
Text File  |  1990-06-16  |  16KB  |  387 lines

  1.  
  2.                 CHIPS Version 1.8
  3.  
  4.              (c) 1990 William C. Parke
  5.  
  6.   CHIPS is an program designed to explore the hardware on an IBM PC
  7. compatible.  It will make a series of tests to determine, as far as
  8. possible, the kind of computer chips present in the particular machine.
  9. These include the Central Processing Unit (CPU), the Numeric Data
  10. Processor (NDP), and the various Asynchronous Communication Elements
  11. (ACEs) used on the serial ports.  CHIPS demonstrates that software is
  12. capable of checking detailed hardware capabilities directly. Programmers
  13. can use more sophisticated coding when more advanced hardware is found.
  14.  
  15.   Run CHIPS with the DOS command:
  16.  
  17.    CHIPS
  18.  
  19.   To save a copy of the hardware configuration, use DOS redirection:
  20.  
  21.    CHIPS >chips.scn
  22.  
  23.   Although the hardware configuration of a computer can be verified by
  24. internal visual inspection, it is not a particularly easy task.
  25. Moreover, the critical question of whether the hardware will respond to
  26. software can be at issue.  CHIPS uses software to make direct tests of
  27. hardware elements.  It goes beyond the assumptions of the operating
  28. system, whose configuration may be at variance with the actual
  29. situation.  Thus, CHIPS will allow one to determine possible conflicts
  30. between the hardware and the settings of the configuration DIP switches
  31. on the motherboard of a PC or the CMOS memory in the AT computer.
  32.  
  33.         The CPU: Central Processing Unit
  34.  
  35.   Because of various quirks, design changes, and design improvements, it
  36. is possible to distinguish between the following types of CPUs:
  37.  
  38.         8088    The original 8/16 bit Intel CPU used in the IBM PC
  39.         8086    The full 16 bit version
  40.         V20     NEC's clone of the 8088 with added 8080 mode
  41.         V30     NEC's clone of the 8086 with added 8080 mode
  42.         80188   An enhanced 8088 with expanded i/o instructions
  43.         80186   An enhanced 8086 with expanded i/o instructions
  44.         80286   The first micro CPU with protected mode
  45.         80386   Extended with 32 bit registers, new instructions
  46.         80486   Integrated with NDP, cache buffer, extended addressing
  47.  
  48.   For the 8088, CHIPS will test for a serious hardware bug in the early
  49. production chips which could cause the computer to halt during a program
  50. execution.  For the 80386, CHIPS looks for the infamous 'multiply bug'
  51. in early production runs.  A double sigma (printed on the chip) means
  52. the chip passed Intel's tests.  If CHIPS confirms this test, it will
  53. print a double sigma after the chip name.
  54.  
  55.   CHIPS next determines the speed of the CPU and the number of effective
  56. wait states currently used by the CPU in accessing memory.  These
  57. are printed after the CPU identification.
  58.  
  59.         The Interrupt Controllers
  60.  
  61.   The orginal IBM PC used the Intel 8259 chip to manage the various
  62.   hardware interrupts from the keyboard, drives, clock, ports, etc.  The
  63.   AT machine cascaded the master 8259 with a slave 8259 controller,
  64.   expanding the number of hardware interrupt lines from eight to
  65.   fifteen.  CHIPS will report on the existence of one or both of
  66.   these controllers.
  67.  
  68.         The NDP: Numeric Data coProcessor
  69.  
  70.   CHIPS will also test for the Numeric Data Processor (math coprocessor)
  71. to see if it is available to accompany the CPU.  [Note: The NDP is
  72. integrated into the 80486.]   Function and designed improvements in the
  73. NDP allow software to distinguish between the following possibilities:
  74.  
  75.         no coprocessor
  76.         8087    NDP to accompany the 8088/8086
  77.         80287   NDP to accompany the 80286 or the 80386
  78.         80387   NDP to accompany the 80386
  79.  
  80.         The ACEs: Asynchronous Communication Elements
  81.  
  82.   The serial ports on the IBM PC are controlled by an Intel 8250 or its
  83. equivalent.  Most PCs have at least one 8250.  Some serial cards use a
  84. faster version, the 16450 or the 16550.  A more advanced chip, the
  85. 16550AN, contains an internal 16 byte buffer, useful in multitasking
  86. operations.  CHIPS can distinguish:
  87.  
  88.         no ACEs on any ports
  89.         8250    Serial controllers
  90.         16450   Serial controllers, extended version of the 8250
  91.         16550   Serial controllers, faster version of the 8250
  92.         16550AN Serial controllers, with FIFO buffer.
  93.  
  94.         The Parallel and Game Ports
  95.  
  96.   The IBM PC add-on cards generally do not use an intelligent chip to
  97. control the printer ports or the game port.  Instead, these ports, when
  98. available, are controlled by logic chips.  CHIPS will search for real
  99. ports at the default locations.
  100.  
  101.         Display of IBM BIOS Assumptions for Attached Devices
  102.  
  103.   At boot time, the IBM PC and AT reads the user configuration settings
  104. for various devices which may be attached to the system.  Some of this
  105. information is stored in the BIOS (Basic Input/Output System) memory.
  106. CHIPS will allow you to compare the actual hardware it found with the
  107. settings recorded in the BIOS memory.  In the case of the NDP, CHIPS
  108. shows the BIOS NDP-present flag (yes or no).  For the serial ports,
  109. CHIPS will give the current name assigned by DOS to the ports used for
  110. serial devices.  This assignment may vary, as it is can be changed using
  111. various swapping or redirection utilities.  CHIPS reports the same kind
  112. of information for the parallel (printer) ports.  After showing if the
  113. game port is active, CHIPS gives the setting of the BIOS equipment flag
  114. for this port.  A test is also made to see if a mouse driver has been
  115. installed in the memory of the machine.
  116.  
  117.         Mouse Support
  118.  
  119. Chips can distinguish a serial, bus, and PS/2 mouse when a mouse
  120. driver is present.
  121.  
  122.         Sound Support
  123.  
  124. Chips will test for a MIDI or AdLib port and accompanying driver.
  125.  
  126.  
  127.         Example of CHIPS Display:
  128.  
  129. Chip Identification V1.8ß (c) William C. Parke 1990
  130.  
  131.  Central Processing Unit: -8088-- 8 MHz with 0 wait states.
  132.      8088 interrupt test: Passed.
  133.         Math coprocessor: -8087-- Present and flagged in BIOS.
  134.    Interrupt Controllers: Master 8259 Found, Slave 8259 Not Found.
  135.        Serial port  3F8H: -8250-- Active.
  136.               port  2F8H: -8250-- Active.
  137.               port  3E8H: Not Active.
  138.               port  2E8H: Not Active.
  139.      Parallel port  3BCH: ------- Active as LPT1: 
  140.               port  378H: ------- Active as LPT2: 
  141.               port  278H: Not Active.
  142.          Game port  201H: Not Active and not flagged in BIOS.
  143.        Sound I/O support: PC Speaker.
  144.                    Mouse: No Driver Found.
  145.  
  146.  
  147. Technical Details:
  148.  
  149. Distinguishing CPUs
  150.  
  151.     "8088 programmable registers and addressing modes are
  152.     identical to the 8086 in every way.  Except for execution
  153.     speed, to the programmer the 8088 is identical to the 8086."
  154.     (Osborne/McGraw-Hill, Russell Rector and George Alexy, The
  155.     8086 Book, 1980)
  156.  
  157.   A statement such as the above is a challenge to programmers!  The
  158. second sentence turns out to be wrong.  There is a trivial software test
  159. one can make to distinguish the 8088 from the 8086 (and the 80188 from
  160. the 80186), despite the claims that the only difference between these
  161. chips is the treatment of the external data hardware lines.
  162.  
  163.   The test in question takes advantage of the fact that the 8088 has
  164. a 4-byte prefetch queue, while the 8086 has a 6-byte prefetch queue.
  165. This means that these chips pull the next set of instructions to
  166. be executed into an internal buffer.  Now suppose we instruct the CPU
  167. to change one of the memory locations which had just been prefetched.
  168. Then the code at that location will not be the same as the prefetched
  169. code.  On the other hand, if the change is made to the code in memory
  170. just out of reach of the 8088, but still within reach of the 8086
  171. prefetch operations, these chips will execute different instructions.
  172. For example,
  173.  
  174.                 XOR     CX,CX
  175.                 CLI
  176.                 MOV     BYTE PTR [NEXT],NOP
  177.                 NOP
  178.         NEXT:   INC     CX
  179.                 STI
  180.                 JCXZ    8088
  181.  
  182. will result in CX=1 on the 8086, but CX=0 on the 8088.
  183.  
  184.   The 80186 can be distinquished from the 8086 using a variety of
  185. software differences.  One of the simplest is the shift operation.
  186. Chips after the 8086 do not waste time bit shifting more than 32
  187. times (the maximum size of any one register), so the shift value
  188. (in the CL register) is truncated modulo 32 before the operation.
  189. Thus:
  190.  
  191.  
  192.         MOV     CL,33                   ; 8018x shifts modulo 32
  193.         SHL     CL,CL
  194.         JCXZ    8088
  195.  
  196. will result in a non-zero flag being set if the chip is above the 8088
  197. generation, since only a single bit shift occurs in that case.
  198.  
  199.   The 8088 and 8086 differ from the 80286 and later chips in how they
  200. handle the value of the stack pointer when it is pushed onto the
  201. stack:
  202.  
  203.                 PUSH    SP
  204.                 POP     AX
  205.                 CMP     AX,SP
  206.                 JNZ     8088
  207.  
  208. After the above operation, AX will contain the value of the stack pointer
  209. before the push if the chip is an 80286 or later.
  210.  
  211.   The V20/V30 chips can be detected by executing extended V20 code which
  212. also is meaningful on the 8088.  For example,
  213.  
  214.                 SET1    CX,0            ; v20 code
  215.  
  216. sets a bit in the CX register.  On the 8088 this code is
  217.  
  218.                 POP     CS
  219.                 SBB     AX,0C1H
  220.  
  221. which does not affect the CX register.  However, this code must be avoided
  222. on an 80386 machine, which can lock at the POP CS.  A simpler test
  223. is the following:
  224.  
  225.                 XOR     AL,AL
  226.                 MOV     AL,40H
  227.                 MUL     AL
  228.                 JZ      NEC
  229.  
  230. since the 8088 will set NZ on multiply while the NEC does not.
  231.  
  232.   The 80386 handles more flag register bits than the 80286.  By trying
  233. to set the upper four bits of the flag register and then testing:
  234.  
  235.                 MOV     AX,0F000H
  236.                 PUSH    AX
  237.                 POPF
  238.                 PUSHF
  239.                 POP     AX
  240.                 AND     AX,0F000H
  241.                 JZ      80286
  242.  
  243. the upper four bits will be reset on chips below the 80386.
  244.  
  245.   The 80486 can be distinquished from the 80386 by the fact that its
  246. prefetch queue is 32 bytes in size instead of 16 bytes.  The test
  247. code is similar to that above which separates the 8088 from the
  248. 8086, except one needs 15 nops instead of one.  Alternatively, one
  249. can attempt to set the 29th bit of the CR0 register (cache write-through
  250. bit), which cannot be set on the 80386:
  251.  
  252.         MOV     EAX,CR0         ; 0FH,20H,0C0H
  253.         MOV     EBX,EAX         ; 66H,8BH,0D8H
  254.         XOR     EAX,20000000H   ; 66H,35H,00H,00H,00H,20H
  255.         MOV     CR0,EAX         ; 0FH,22H,0C0H
  256.         MOV     EAX,CR0         ; 0FH,20H,0C0H
  257.         CMP     EAX,EBX         ; 66H,3BH,0C3H
  258.         JZ      80386
  259.  
  260. CPU speed tests are made by timing repeated CPU divide instructions.
  261.  
  262. Wait states are extimated by the time required to make repeated
  263. memory-to-memory moves.
  264.  
  265.  
  266. Finding the Numeric Data coProcessor:
  267.  
  268.  
  269.    Attempting to execute commands designed for the math coprocessor
  270. on a system without one is a delicate matter.  Some instructions
  271. will cause particular CPUs to lock up.  (Unfortunately, FSTENV, which
  272. could be used to save the current state of the coprocessor, freezes
  273. PS/2-55 80386SX machines).  Others require the CPU to wait for the
  274. coprocessor to finish its task before continuing.  Assemblers and
  275. compilers often insert the WAIT instruction in such cases.  However,
  276. asking a CPU to WAIT when there is no coprocessor is asking it to wait
  277. forever.  It appears that
  278.  
  279.         FINIT                   ; initialize coprocessor
  280.         JMP $+2
  281.         JMP $+2
  282.         JMP $+2                 ; imitate a wait
  283.         FSTCW WORD PTR NDPCW    ; store NDP control word
  284.         MOV AX,WORD PTR NDPCW
  285.         AND AH,11111B           ; isolate inf,rounding,precision bits
  286.         CMP AH,,00011B
  287.         JZ GOT_NDP
  288.  
  289. will pass through the digestive tracks of the 80x86 series without
  290. blockage, even when no coprocessor is connected.  When there is a
  291. coprocessor, the control word bits 8-12 will be set to indicate the
  292. default 64 bit precision, nearest rounding, and projective infinity.
  293.  
  294.   To differentiate an 8087 from an 80287 or later, one can drop the
  295. interrupt-enable-mask bit of the control register, disable interrupts,
  296. read the register back, and check if the mask bit is still 0 (interrupts
  297. still enabled):
  298.  
  299.         AND     WORD PTR NDPCW,0FF7FH    ; drop bit 7 IEM inter enable mask
  300.         FLDCW   WORD PTR NDPCW           ; load control word into NDP
  301.         FDISI                            ; disable interrupts (ignored on 287)
  302.         FSTCW   WORD PTR NDPCW           ; store control word in memory
  303.         TEST    WORD PTR NDPCW,80H       ; is IEM of control word back again?
  304.         JNZ     80287
  305.  
  306. The 80387 will reset the zero flag bit in its status register on
  307. initialization, but the 80287 will not:
  308.  
  309.         FLDZ                            ; zero st(0)
  310.         FXAM                            ; set status flags
  311.         FINIT                           ; reset 80x87
  312.         FSTSW   WORD PTR NDPSW          ; get status word
  313.         TEST    BYTE PTR NDPSW+1,01000000B      ; check C3 = ZF
  314.         JNZ     80287                   ; 80287 does not reset ZF
  315.  
  316.  
  317. Testing for Real Serial Ports:
  318.  
  319.    A relatively straight foward test can determine if the standard
  320. serial ports have an active chip controlling them.  For example, reading
  321. in the line-control register, reversing its first six bits, sending the
  322. reversed set out, reading it back in, then checking if the new bits
  323. are as they were sent out.  Of course, this testing should be done
  324. with interrupts turned off, and the original register value restored
  325. before turning them back on:
  326.  
  327.         MOV     DX,3FCH         ; first serial port + 2
  328.         IN      AL,DX           ; get line control reg
  329.         MOV     BL,AL           ; save
  330.         CLI
  331.         XOR     AL,0111111B     ; reverse bits
  332.         MOV     BH,AL           ; save reversed value
  333.         OUT     DX,AL
  334.         JMP     $+2
  335.         IN      AL,DX
  336.         MOV     AH,AL           ; save read value
  337.         MOV     AL,BL           ; get original line control
  338.         OUT     DX,AL           ; restore original
  339.         STI
  340.         CMP     AH,BH           ; see if it changed
  341.         JZ      GOT_COM
  342.  
  343. The 16450 chips has an additional eighth read/write port, which
  344. can be tested for.
  345.  
  346. To tell if one of the newer 16550 or 16550AN chips is present,
  347. one can use the two new bits (6-7) in the interrupt-identification
  348. register.  These bits, when set, clear and enable the FIFO internal
  349. receive buffer.  These chips are distinquishable by whether these
  350. bits can be set:
  351.                 bits 7  6
  352.                      0  0   8250 ACE
  353.                      0  1   unknown
  354.                      1  0   16550
  355.                      1  1   16550AN
  356.  
  357.  
  358. Parallel Port Testing:
  359.  
  360.   A live parallel port can have its interrupt-enable bit set at the
  361. control register port.  Testing if this bit can be toggled serves as an
  362. appropriate probe.  The testing must be done with software interrupts
  363. turned off as there may not be any interrupt handler for the parallel
  364. port.  (Moreover, the original IBM PC had a hardware fault which
  365. prevented proper parallel port interrupt handling.)
  366.  
  367. Mouse Presence:
  368.  
  369.   There is no standard mouse port on the IBM PC.  One can operate a
  370. mouse from a serial port, a bus card, or through the PS/2 keyboard
  371. controller.
  372.  
  373.   CHIPS can look for a mouse driver interface in software.  If the
  374. driver is present, there is a very good chance the system has the
  375. necessary hardware for a mouse.  CHIPS attempts to find if the mouse
  376. driver has taken over a serial port interrupt.  It will look at
  377. the keyboard controller for a PS/2 mouse.
  378.  
  379. Sound Ports:
  380.  
  381.   The MIDI-401 (musical instrument digital interface) takes the ports
  382. 330H and 331H.  CHIPS tries to get an acknowledgement to a status read
  383. of a possible MIDI card.  An AdLib music card uses the port 388H.  CHIPS
  384. attempts to initialize the AdLib music card.  If successful, it will
  385. look for an AdLib driver, which uses interrupt 65h.
  386.  
  387.